<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>购物车列表</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
* {
	font-size: 11pt;
}

div {
	margin: 20px;
	border: solid 0px gray;
	width: 150px;
	height: 150px;
	text-align: center;
}

li {
	margin: 10px;
}

#buy {
	background: url(<c:url value='/images/all.png'/>) no-repeat;
	display: inline-block;
	background-position: 0 -902px;
	margin-left: 30px;
	height: 36px;
	width: 146px;
}

#buy:HOVER {
	background: url(< c : url value = '/images/all.png'/ >) no-repeat;
	display: inline-block;
	background-position: 0 -938px;
	margin-left: 30px;
	height: 36px;
	width: 146px;
}
</style>
</head>

<body>

	<c:choose>
	<%--当session中没有购物车或者购物车中没有内容 --%>
		<c:when
			test="${empty sessionScope.cart or fn:length(sessionScope.cart.cartItems) eq 0 }">
			<image src="<c:url value='/images/emptycart.png'/>" width="150">
		</c:when>
		<c:otherwise>


			<table border="0" width="100%" cellspacing="0" background="black">
				<tr>
					<td colspan="7" align="right"
						style="font-size: 15pt; font-weight: 900"><a
						href="<c:url value='/cartclear'/>">清空购物车</a>
					</td>
				</tr>
		
				<c:forEach items="${sessionScope.cart.cartItems }" var="cartItem">
					<tr>
						<td>
							<div>
								<img src="<c:url value='/${cartItem.book.image }'/>" />
							</div>
						</td>
						<td>${cartItem.book.bname }</td>
						<td>${cartItem.book.author }</td>
						<td>${cartItem.book.price }元</td>
						<td>${cartItem.count }</td>
						<td>${cartItem.subtotal }元</td>
						<td>
							<a href="<c:url value='/cartdelete?bid=${cartItem.book.bid }'/>">删除</a>
						</td>
					</tr>

				</c:forEach>
				<tr>
					<td colspan="7" align="right"
						style="font-size: 15pt; font-weight: 900">
						合计：${sessionScope.cart.total }元</td>
				</tr>
				<tr>
					<td colspan="7" align="right"
						style="font-size: 15pt; font-weight: 900">
						<a id="buy" href="<c:url value='/orderadd'/>"></a>
					</td>
				</tr>
			</table>
		</c:otherwise>
	</c:choose>
</body>
</html>
